﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ShadowCommando.GameMenus
{
    /// <summary>
    /// Kontrolka reprezentująca przycisk w  menu dziedziczy po Label
    /// </summary>
    public partial class ButtonMenu : Label
    {
        private NameButton nameButton;
        private Font fontHoverLabel = GameMenuSettings.Default.fontHover;
        private Font fontLeaveLabel = GameMenuSettings.Default.fontLeave;
        private Color fontColor = GameMenuSettings.Default.fontColor;

        private Label label;
        /// <summary>
        /// Label
        /// </summary>
        public Label Label
        {
            get
            {
                return label;
            }
            set
            {
                label = value;
            }
        }

        /// <summary>
        /// Rodzaj przycisku
        /// </summary>
        public NameButton NameButton
        {
            get
            {
                return nameButton;
            }
            set
            {
                nameButton = value;
            }
        }
        /// <summary>
        /// Konstruktor
        /// </summary>
        public ButtonMenu()
        {
            InitializeComponent();
            DoubleBuffered = true;
        }
        /// <summary>
        /// Zmiana tekstu w przycisku
        /// </summary>
        /// <param name="text">Nowy tekst</param>
        public void ChangeText(string text)
        {
            label.Text = text;
        }
        /// <summary>
        /// Konstruktor
        /// </summary>
        /// <param name="name">Rodzaj przycisku</param>
        /// <param name="text">Tekst</param>
        public ButtonMenu(NameButton name, string text)
        {
            InitializeComponent();
            nameButton = name;
            BackColor = Color.Transparent;
            this.Tag = name;
            label = CreateLabel(name.ToString(), text);
            label.Tag = name;
            label.Top = 0;
            this.Controls.Add(label);
            this.Height = fontHoverLabel.Height;
            this.Width = label.Width;
        }
        private Label CreateLabel(string name, string text)
        {
            Label label = new Label();
            label.AutoSize = true;
            label.Name = name;
            label.Text = text;
            label.Font = fontLeaveLabel;
            label.Height = label.Font.Height;
            label.ForeColor = fontColor;
            label.MouseEnter += new EventHandler(OnMouseHoverLabel);
            label.MouseLeave += new EventHandler(OnMouseLeaveLabel);
            return label;
        }


        private void OnMouseHoverLabel(object sender, EventArgs e)
        {
            Label label = sender as Label;
            label.Font = fontHoverLabel;
        }
        private void OnMouseLeaveLabel(object sender, EventArgs e)
        {
            Label label = sender as Label;
            label.Font = fontLeaveLabel;

        }
    }
}
